package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ScenicSpots;
import com.ruoyi.system.service.IScenicSpotsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 景区模块Controller
 * 
 * @author lsj
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/system/scenicSpots")
public class ScenicSpotsController extends BaseController
{
    @Autowired
    private IScenicSpotsService scenicSpotsService;

    /**
     * 查询景区模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:scenicSpots:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScenicSpots scenicSpots)
    {
        startPage();
        List<ScenicSpots> list = scenicSpotsService.selectScenicSpotsList(scenicSpots);
        return getDataTable(list);
    }

    /**
     * 导出景区模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:scenicSpots:export')")
    @Log(title = "景区模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScenicSpots scenicSpots)
    {
        List<ScenicSpots> list = scenicSpotsService.selectScenicSpotsList(scenicSpots);
        ExcelUtil<ScenicSpots> util = new ExcelUtil<ScenicSpots>(ScenicSpots.class);
        util.exportExcel(response, list, "景区模块数据");
    }

    /**
     * 获取景区模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:scenicSpots:query')")
    @GetMapping(value = "/{scenicSpotid}")
    public AjaxResult getInfo(@PathVariable("scenicSpotid") Long scenicSpotid)
    {
        return success(scenicSpotsService.selectScenicSpotsByScenicSpotid(scenicSpotid));
    }

    /**
     * 新增景区模块
     */
    @PreAuthorize("@ss.hasPermi('system:scenicSpots:add')")
    @Log(title = "景区模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScenicSpots scenicSpots)
    {
        return toAjax(scenicSpotsService.insertScenicSpots(scenicSpots));
    }

    /**
     * 修改景区模块
     */
    @PreAuthorize("@ss.hasPermi('system:scenicSpots:edit')")
    @Log(title = "景区模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScenicSpots scenicSpots)
    {
        return toAjax(scenicSpotsService.updateScenicSpots(scenicSpots));
    }

    /**
     * 删除景区模块
     */
    @PreAuthorize("@ss.hasPermi('system:scenicSpots:remove')")
    @Log(title = "景区模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scenicSpotids}")
    public AjaxResult remove(@PathVariable Long[] scenicSpotids)
    {
        return toAjax(scenicSpotsService.deleteScenicSpotsByScenicSpotids(scenicSpotids));
    }
}
